<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>样板合同</title>
		<script src="js/jquery-3.3.1.min.js"></script>
		<link rel="stylesheet" type="text/css" href="./css/modelContract.css" />
		<!-- 微信 JS-SDK 如果不需要兼容小程序，则无需引用此 JS 文件 -->
		<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
		<!-- uni 的 SDK -->
		<script type="text/javascript" src="http://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.0.2.2.js"></script>
	</head>
	<body>
		<div id='modelContract' class='modelContract'>
			<div class='details'>
				<div class='content' v-if='content' v-html='content'></div>
				<div class='nodata' v-if='nodata'>暂无内容</div>

			</div>

		</div>
		<script src="./js/vue.js"></script>
		<script src="./js/elementui.js"></script>

		<script type="text/javascript">
			let loaded = false;
			document.addEventListener("plusready", function() {
				if (loaded) plus.nativeUI.closeWaiting()
			})
			
			new Vue({
				el: '#modelContract',
				data() {
					return {
						params: {
							movieId: ''
						},

						content: '',
						nodata: false,
					}
				},
				methods: {
					getQueryString(name) {
						var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
						var r = window.location.search.substr(1).match(reg);
						if (r != null) {
							return unescape(r[2]);
						}
						return '';
					},

					getData() {
						let _this = this;
						console.log(this.getQueryString("movieId"))
						this.params.movieId = parseInt(this.getQueryString("movieId"));
						$.ajax({
							url: "http://grys.nervenets.com/api/v1/movieDetail",
							method: 'post',
							data: this.params,
							success: function(json) {
								if (json.status) {
									_this.content = json.data.info.contractDetail;
									_this.nodata = !Boolean(_this.content)
								}
								loaded = true
								if (typeof plus !== "undefined") {
									plus.nativeUI.closeWaiting()
								}
								
								setTimeout(function() {
									let urls = [];
									$(".content img").each(function(index) {
										$(this).attr("index", index)
										urls.push($(this).attr("src"))
									})
									console.log(urls)
									$(".content img").click(function(index) {
										console.log($(this).attr("index"))
										if (typeof plus !== "undefined") {
											plus.nativeUI.previewImage(urls, {
												current: $(this).attr("index"),
												indicator: "number"
											})
										}
										console.log($(this).attr("src"))
									})
								}, 200)
								
							}
						});
					}

				},
				mounted() {
					this.getData();
					document.title = '样板合同';
				}
			});
		</script>
	</body>
</html>
